package com.zcpt.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zcpt.mapper.UserMapper;
import com.zcpt.pojo.users.User;
import com.zcpt.realname.IUserService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class UserServiceImpl implements IUserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public void addUser(User user) {
        userMapper.insert(user);
    }

    //修改user中的is_realname_check状态
    @Override
    public void modifyUserStatus(Integer id) {
        User user = new User();
        user.setId(id);
        user.setIsRealnameCheck("1");
        userMapper.updateById(user);
    }

    @Override
    public boolean queryfromUsername(String username) {
        User user = userMapper.selectOne(new QueryWrapper<User>().eq("username", username));
        if (user != null)
        return false;
        else return true;
    }

    //根据用户名查找用户
    @Override
    public User queryByUsername(String username) {
        User user = userMapper.selectOne(new QueryWrapper<User>().eq("username", username));
        return user;
    }
}
